import win32api
import getdata
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import cm, mm, inch, pica
from PIL import Image
import glob, os
import string, os, sys, imp, time
from reportlab.lib.logger import warnOnce
from types import *

getdata.cursor.execute( "select id,tarih,cari_kod from sipfis where fis_tipi=2 and fis_no=140")
data = getdata.cursor.fetchall()

print data[0][2]
firma= data[0][2]
tarih=data[0][1]
tarih=str(tarih.day)+"/"+str(tarih.month)+"/"+str(tarih.year)
print tarih
firma=firma.decode("iso-8859-9")
pdf = Canvas("test.pdf")
pdf.setFont("Courier", 12)
pdf.setStrokeColorRGB(1, 0, 0)
pdf.drawImage("splash.jpg",cm ,cm * 28 , width=5*cm,height=2*cm)

pdf.drawString(50,500,firma)
pdf.drawString(110,500,tarih)
rhyme = pdf.beginText(inch * 1, inch * 10)

a="1- "
b="KASTPLY  "
c="POLYESTER ASTAR"
d="      "
e="333.00 MT"

rhyme.textLine(a+b+c+d+e)
rhyme.textLine("All the king's horses and all the king's men")
rhyme.textLine("Couldn't put Humpty together again.")

pdf.drawText(rhyme)

pdf.showPage()

pdf.save()

os.startfile("test.pdf")
#win32api.ShellExecute (0, "print", "test.pdf", None, ".", 0)
